package com.android.cl.coludtf.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageButton;

import com.android.cl.coludtf.R;
import com.android.cl.coludtf.activity.base.BaseActivity;
import com.android.cl.coludtf.adapter.TenantAdapter;
import com.android.cl.coludtf.model.BaseBO;
import com.android.cl.coludtf.model.Tenants;
import com.android.cl.coludtf.utils.sharedPreferences.DatabaseHelper;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class Tenant extends BaseActivity {
    BaseBO bo;
    @BindView(R.id.Img_Ten_Back)
    ImageButton ImgTenBack;
    @BindView(R.id.Img_Set_Tenant)
    ImageButton ImgSetTenant;
    @BindView(R.id.Gv_Tenant)
    GridView GvTenant;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tenant);
        ButterKnife.bind(this);
        initData();
    }

    @OnClick({R.id.Img_Ten_Back, R.id.Img_Set_Tenant})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.Img_Ten_Back:
                finish();
                break;
            case R.id.Img_Set_Tenant:
                break;
        }
    }

    private void initData() {
        bo = DatabaseHelper.getBaseBO();
        List<Tenants> tenants = gson.fromJson(bo.tenants, new TypeToken<List<Tenants>>() {
        }.getType());
        TenantAdapter adapter = new TenantAdapter(tenants);
        GvTenant.setAdapter(adapter);
        GvTenant.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                                            @Override
                                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                                            }
                                        }

        );
    }
}